/*
*************************************************************************
*西瑞克斯通信技术股份有限公司研发管理系统
*版 本: 1.0   
*日 期：02/05/2012    
*作 者： 王浩 QQ:873987060   
*************************************************************************   
*/  
package com.application.projectview.struts.action;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.application.projectview.commons.Constants;
import com.application.projectview.service.ProjectViewService;
import com.application.projectview.struts.form.ProjectViewForm;
import com.application.yfproject.entity.YfProject;
import com.manager.commons.CommonUtil;


public class ProjectViewAction extends DispatchAction {

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	private ProjectViewService projectViewService;

    
	/**
	 * 获得相应项目视图
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward enterProjectView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("enterProjectView" + "开始");
		ProjectViewForm projectViewForm = (ProjectViewForm) form;
//		projectViewForm = projectViewService.findProjectViewForm(projectViewForm);
		findProjectViewItem(projectViewForm, request);
		log.debug("enterProjectView" + "结束");
		return mapping.findForward(Constants.SUCCESS);
	}



	/**
	 * 获得项目视图中已经完成项目列表
	 */
	private void findProjectViewItem(ProjectViewForm projectViewForm,HttpServletRequest request) {
		String projectNo = projectViewForm.getProjectNo();
		String rfpsID = projectViewForm.getId();
		//已经完成的内容标题
        Map titleList = new LinkedHashMap();
//    	titleList.put("#fqxm","发起项目");
//    	titleList.put("#zlgd","资料归档");
//    	titleList.put("#jdzt","项目节点状态");
//    	titleList.put("#xmhy","项目会议");

        YfProject yfProject = projectViewService.findYfproject(rfpsID);
        request.setAttribute("yfProject",yfProject);
        request.setAttribute("orgSelect", CommonUtil.getOrgSelectNoZB());
 
        
    	List xmdyList = projectViewService.findYfxmdy(projectNo);
    	if(xmdyList!=null && xmdyList.size()>0){
    		request.setAttribute("xmdy", xmdyList);
    		titleList.put("#xmdy","项目调研");
    	}
		

        
    	List lxsqList = projectViewService.findYflxsq(projectNo);
    	if(lxsqList!=null && lxsqList.size()>0){
    		titleList.put("#lxsq","立项申请");
		    request.setAttribute("lxsq", lxsqList);
    	}
     
    	List wxhtList = projectViewService.findYfwxht(projectNo);
    	if(wxhtList!=null && wxhtList.size()>0){
    		titleList.put("#wxht","外协合同");
			request.setAttribute("wxht", wxhtList);
    	}
		
    	List xmjhList = projectViewService.findYfxmjh(projectNo);
    	if(xmjhList!=null && xmjhList.size()>0){
    		titleList.put("#xmjh","项目计划");
			request.setAttribute("xmjh", xmjhList);
    	}
    	
    	List gysjList = projectViewService.findYfgysj(projectNo);
		if(gysjList!=null && gysjList.size()>0){
			titleList.put("#gysj","概要设计");
			request.setAttribute("gysj", gysjList);
		}
		
		List yjxxsjList = projectViewService.findYfyjxxsj(projectNo);
		if(yjxxsjList!=null && yjxxsjList.size()>0){
			titleList.put("#yjxxsj","硬件子系统详细设计");
			request.setAttribute("yjxxsj", yjxxsjList);
		}
		
		List rjxxsjList = projectViewService.findYfrjxxsj(projectNo);
		if(rjxxsjList!=null && rjxxsjList.size()>0){
			titleList.put("#rjxxsj","软件子系统详细设计");
			request.setAttribute("rjxxsj", rjxxsjList);
		}
		
		List jksjList = projectViewService.findYfjksj(projectNo);
		if(jksjList!=null && jksjList.size()>0){
			titleList.put("#jksj","接口设计");
			request.setAttribute("jksj", jksjList);
		}
		
		List kfssr1List = projectViewService.findResearch1(projectNo);
		if(kfssr1List!=null && kfssr1List.size()>0){
			titleList.put("#kfssr1","软件 --- 编码");
			request.setAttribute("kfssr1", kfssr1List);
		}
		
		List kfssr2List = projectViewService.findResearch2(projectNo);
		if(kfssr2List!=null && kfssr2List.size()>0){
			titleList.put("#kfssr2","软件 --- 单元测试");
			request.setAttribute("kfssr2", kfssr2List);
		}
		
		List kfssr3List = projectViewService.findResearch3(projectNo);
		if(kfssr3List!=null && kfssr3List.size()>0){
			titleList.put("#kfssr3","软件 --- 子系统测试");
			request.setAttribute("kfssr3", kfssr3List);
		}
		
		List kfssr4List = projectViewService.findResearch4(projectNo);
		if(kfssr4List!=null && kfssr4List.size()>0){
			titleList.put("#kfssr4","硬件 --- 原理图");
			request.setAttribute("kfssr4", kfssr4List);
		}
		
		List kfssr5List = projectViewService.findResearch5(projectNo);
		if(kfssr5List!=null && kfssr5List.size()>0){
			titleList.put("#kfssr5","硬件 --- PCB");
			request.setAttribute("kfssr5", kfssr5List);
		}
		
		List kfssr6List = projectViewService.findResearch6(projectNo);
		if(kfssr6List!=null && kfssr6List.size()>0){
			titleList.put("#kfssr6","软硬联调");
			request.setAttribute("kfssr6", kfssr6List);
		}
		
		List kfssr7List = projectViewService.findResearch7(projectNo);
		if(kfssr7List!=null && kfssr7List.size()>0){
			titleList.put("#kfssr7","硬件 --- 子系统调试");
			request.setAttribute("kfssr7", kfssr7List);
		}
		
		List kfssr8List = projectViewService.findResearch8(projectNo);
		if(kfssr8List!=null && kfssr8List.size()>0){
			titleList.put("#kfssr8","研发测试");
			request.setAttribute("kfssr8", kfssr8List);
		}
		
		List zsList = projectViewService.findYfProjectPilot(projectNo);
		if(zsList!=null && zsList.size()>0){
			titleList.put("#zs","中试");
			request.setAttribute("zs", zsList);
		}
		
		List ysspList = projectViewService.findYfProjectAccept(projectNo);
		if(ysspList!=null && ysspList.size()>0){
			titleList.put("#yssp","验收审批");
			request.setAttribute("yssp", ysspList);
		}
		
		List ylList = projectViewService.findYfMaterielDepart1(projectNo);
		if(ylList!=null && ylList.size()>0){
			titleList.put("#yl","物料");
			request.setAttribute("yl", ylList);
		}
		
		List sbList = projectViewService.findYfMaterielDepart2(projectNo);
		if(sbList!=null && sbList.size()>0){
			request.setAttribute("sb", sbList);
			titleList.put("#sb","设备");
		}
		
		request.setAttribute("counts", titleList.size());
		request.setAttribute(Constants.TITLE_LIST,titleList);
	}

	public ProjectViewService getProjectViewService() {
		return projectViewService;
	}
	public void setProjectViewService(ProjectViewService projectViewService) {
		this.projectViewService = projectViewService;
	}

}
